package com.rew.canteenchefs.models;

import java.util.ArrayList;
import java.util.List;

/**
 *  User Orders.
 *
 * Created by HuiWen Ren on 2016/12/3.
 */
public class Orders {

    private List<EDishes> dishesList;

    public Orders(){
        dishesList = new ArrayList<>();
    }

    private boolean packing = false;

    /**
     * 留给前端的接口.
     * @param dishesList dishesList
     */
    public void addList(List<EDishes> dishesList){
        this.dishesList = dishesList;
    }

    public void addList(List<EDishes> dishesList, boolean packing){
        this.dishesList = dishesList;
        this.packing = packing;
    }
    /**
     * 暂时添加订单的方法.
     *
     * @param dishName dishName
     * @param dishNum dishNum
     */
    public void addOrder(String dishName, int dishNum){
        for(int i = 0; i <= dishesList.size(); i++){
            if(i == dishesList.size()){
                dishesList.add(new EDishes(dishName, dishNum));
                break;
            }
            if(dishesList.get(i).getDishName().equals(dishName)){
                int n = dishesList.get(i).getDishNum();
                dishesList.get(i).setDishNum(n + dishNum);
            }
        }
    }

    public boolean isPacking() {
        return packing;
    }

    public void setPacking(boolean packing) {
        this.packing = packing;
    }
}
